﻿<div class="language">
    <FluentButton id="cultureBtn"
                  Appearance="Appearance.Lightweight"
                  BackgroundColor="#0000"
                  Color="@ConfigurationConsts.HeaderColor"
                  IconEnd="@(new Icons.Regular.Size20.Globe().WithColor(ConfigurationConsts.HeaderColor))"
                  Title="多语言"
                  OnClick="@(() => _showMenu = !_showMenu)"/>

    <FluentMenu Anchor="cultureBtn" @bind-Open="_showMenu" @onmenuchange=OnMenuChange VerticalThreshold="170">
        @foreach (var item in CultureOptions)
        {
            <FluentMenuItem OnClick="@((e) => Culture = item.Value!)">
                @item.Text
            </FluentMenuItem>
        }
    </FluentMenu>
</div>


@code {
    private bool _showMenu = false;
    private string _status = "";
    
    private void OnMenuChange(MenuChangeEventArgs args)
    {
        if (args is not null && args.Value is not null)
            _status = $"Item \"{args.Value}\" clicked";
        Console.WriteLine(_status);
    }

}